use serde::{Serialize, Deserialize};

// https://tauri.app/zh/v1/guides/features/command

// 返回的参数必须实现 Serialize 特征
#[derive(Serialize)]
pub struct OsInfo {
  pub info: String,
  pub ostype: String,
  pub version: String,
  pub bitness: String,
}


#[tauri::command]
pub fn get_sym_info(invoke_message: String) -> OsInfo {
  println!("rust get_sym_info runing, patams -> {}", invoke_message);

  let info = os_info::get();

  OsInfo {
    info: info.to_string(),
    ostype: info.os_type().to_string(),
    version: info.version().to_string(),
    bitness: info.bitness().to_string()
  }
}

// 接收的参数必须实现 Serialize, Deserialize 特征
#[derive(Serialize, Deserialize, Debug)]
pub struct TestMap {
  pub name: String,
  pub age: u16,
}

#[tauri::command]
pub fn test_handle(invoke_params: TestMap) -> TestMap {
  println!("rust test_handle runing, patams -> {:#?}", invoke_params);
  invoke_params
}

// pub fn emitEvent() {

// }